import { onMounted, onUnmounted } from "vue";
import { debounce } from "lodash";

function useResize(func: () => void) {
  const defunc = debounce(func, 100);
  onMounted(() => {
    func();
    window.addEventListener("resize", defunc);
  });
  onUnmounted(() => {
    window.removeEventListener("resize", defunc);
  });
}

export default useResize;
